struct ListNode* swapPairs(struct ListNode* head){
    if (!head || !head->next) {
        return head;
    }

    struct ListNode dummy = { .next = head };
    struct ListNode *prev = &dummy, *curr = head;
    while (curr && curr->next) {
        struct ListNode *q = curr->next;
        prev->next = curr->next;
        curr->next = q->next;
        q->next = curr;

        prev = curr;
        curr = curr->next;
    }

    return dummy.next;
}